/*
* 将时间转化成多少天之前
* */



export default function  timelength(time:string){
    // 将字符创转化成时间,gettime将时间转成数字
    const nian = 31536000 * 1000
    const tian = 86400 * 1000
    const xiaoshi = 3600 *1000
    const fenzhong = 60 *1000
    const time1 = new Date(Date.parse(time.replace("/-/g","/"))).getTime()
    const nowtime = new Date().getTime()
    const jieguo = nowtime - time1
    if(jieguo > nian){
        return Math.floor(jieguo/nian) + "年"
    }else if(jieguo > tian){
        return Math.floor(jieguo/tian) + "天"
    }else if(jieguo > xiaoshi){
        return Math.floor(jieguo/xiaoshi) + "小时"
    }else if(jieguo > fenzhong){
        return Math.floor(jieguo/fenzhong) + "分钟"
    }else{
        return Math.floor(jieguo/nian/1000) + "秒"
    }
}

